#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    char arr[20][20] = { 0 };
    int bian = 0;

    while (scanf("%d", &bian) == 1) {
        for (int i = 0; i < bian; i++) {
            for (int j = 0; j < bian; j++) {
                if (i == 0 || i == bian - 1 || j == 0 || j == bian - 1)
                    printf("* ");
                else
                    printf("  ");
            }
            printf("\n");
        }
    }
    return 0;
}